$(function() {	
		var uName = $.cookie("youleche.u");
		if(uName != null){
			$("#divLogin").html('');
			$("#divLogin").html("<span style=\"color:#666;font-size:12px;\">欢迎你，</span><a  onclick=\"myMeile();\" style=\"cursor:pointer;color:#3CAC7E;font-size:16px;\">" +uName +"</a>&nbsp;&nbsp;<span style=\"color:#ccc;font-size:12px;\">|</span>&nbsp;&nbsp;<a  onclick=\"myMeile();\" style=\"cursor:pointer;color:#666;font-size:12px;\">我的美乐车</a>");
		}else{
//			window.location.href = "noresponse.jsp";
//			return;
		}
		
		//加载车辆报价信息
		var vehicleId = window.location.href.split("=")[1];
		if(vehicleId == ""){
			window.location.href = "404.jsp";
			return;
		}
		$.ajax({
			type: "get",
			dataType: "text",
			url: "cheau.do?action=1&id=" + vehicleId,
			success: function(v){
				eval("var json = " + v);
				if(json.vehicleType == "1"){
					$("#divVehicleType").html("自行车");
				}
				$("#txt_pinpai").val(json.vehicleName);
				$("#txt_Dianpu").val(json.A1);
				$("#houseDescrible").html(json.vehicleDesc);
				$("#infoTitle").val(json.A6);
				$("#txtlinkMan").val(json.linkMan);
				$("#txtlinkPhoneNum").val(json.linkPhoneNum);
				$("#txtelectricitySize").val(json.electricitySize);
				$("#txtbatterySize").val(json.batterySize);
				$("#txtmaxspeed").val(json.maxSpeed);
				$("#txtworkLength").val(json.workLength);
				$("#txtWeight").val(json.maxWeight);
				$("#txtprice").val(json.price);
				var payType = json.A4;
				if(payType !=0){
					$("#payType").val("1");
					$("#txtQiNum").show();
					$("#txtQiNum").val(payType);
					$("#spanQi").show();
					
				}else{
					$("#payType").val("2");
				}
				
				var shenfen = json.A5;
				var countPro=$("#sel_Province").get(0).options.length;
				for(var i=0;i<countPro;i++){
					if($("#sel_Province").get(0).options[i].text == shenfen.split("-")[0])  
					{
						$("#sel_Province").get(0).options[i].selected = true;   
						//$("#sel_Province").trigger('change');
						break;  
					} 
				}
				
				var countCity=$("#sel_City").get(0).options.length;
				for(var i=0;i<countCity;i++){
					if($("#sel_City").get(0).options[i].text == shenfen.split("-")[1])  
					{
						$("#sel_City").get(0).options[i].selected = true;   
						//$("#sel_City").change(onCityChange());
						break;  
					} 
				}
				
				var countArea=$("#sel_County").get(0).options.length;
				for(var i=0;i<countArea;i++){
					if($("#sel_County").get(0).options[i].text == shenfen.split("-")[2])  
					{
						$("#sel_County").get(0).options[i].selected = true;          
						break;  
					} 
				}
				
				var give = json.A7;
				if(give.indexOf("0") >=0){
					$("#chk0").attr("checked", "checked");
				}else if(give.indexOf("1") >=0){
					$("#chk1").attr("checked", "checked");
				}else if(give.indexOf("2") >=0){
					$("#chk2").attr("checked", "checked");
				}else if(give.indexOf("3") >=0){
					$("#chk3").attr("checked", "checked");
				}else if(give.indexOf("4") >=0){
					$("#chk4").attr("checked", "checked");
				}
				
			}
		});
		AreaSelector().init();
		zengsong();
		$("#txt_createTime").datebox("setValue", myformatter(new Date()));
		 $("txt_createTime").datebox({  
	            required:true,  
	            onSelect: function(date){  
	                $("#txt_createTime").val(date);  
	            }  
	        }); 
		$("#bikeType").live("change", function(){
			var vehicleType = $("#bikeType").val();	
			if(vehicleType == "-1"){
				$("#divVehicleType .btn-group&.bootstrap-select").css("border", "rgb(255, 153, 0) 1px solid");
				layer.tips('请选择车辆类型', $("#divVehicleType .btn-group&.bootstrap-select"), {guide: 1});
			}else{
				$("#divVehicleType .btn-group&.bootstrap-select").css("border", "#fff 1px solid");
				layer.closeTips();
			}
		});
		
		$("#txt_pinpai").live("focusin", function(){
			$("#txt_pinpai").css("border", "#ccc 1px solid");
			layer.closeTips();
		});
		
		$("#txt_pinpai").live("focusout", function(){
			var vehicleName = $("#txt_pinpai").val();
			if(vehicleName == ""){
				index = 1;
				$("#txt_pinpai").css("border", "rgb(255, 153, 0) 1px solid");
				layer.tips('请输入车辆品牌(只能是汉字、字母、数字、下划线)', $("#txt_pinpai"), {guide: 1});
			}			
		});
		
		$("#email").live("focusin", function(){
			$("#email").val('');
			layer.closeTips();
		});
		
		$("#email").live("focusout", function(){
			var email = $("#email").val();
			if(email == ""){
				$("#email").css("border", "rgb(255, 153, 0) 1px solid");
				layer.tips('请输入邮箱/手机号/用户名', $("#email"), {guide: 1});
			}
		});
		
		$("#passwordShow").live("focusin", function(){
			layer.closeTips();
		});
		
		$("#txt_Dianpu").live("focusin", function(){
			$("#txt_Dianpu").css("border", "#ccc 1px solid");
			layer.closeTips();
		});
		
		$("#txt_Dianpu").live("focusout", function(){
			var dp = $("#txt_Dianpu").val();
			if(dp == ""){
				$("#txt_Dianpu").css("border", "rgb(255, 153, 0) 1px solid");
				layer.tips('请输入店铺名称(只能是汉字、字母、数字、-)', $("#txt_Dianpu"), {guide: 1});
			}else if(dp.length > 80){
				$("#txt_Dianpu").css("border", "rgb(255, 153, 0) 1px solid");
				layer.tips('店铺名称不能超过80个汉字', $("#txt_Dianpu"), {guide: 1});
			}	
		});
		
		$("#txtbatterySize").live("focusin", function(){
			$("#txtbatterySize").css("border", "#ccc 1px solid");
			layer.closeTips();
		});
		
		$("#txtbatterySize").live("focusout", function(){
			var batterySize = $("#txtbatterySize").val();
			if(batterySize == ""){
				$("#txtbatterySize").css("border", "rgb(255, 153, 0) 1px solid");
				layer.tips('请输入电池负数', $("#txtbatterySize"), {guide: 0});
				return;
			}		
		});
		
		$("#txtlinkPhoneNum").live("focusin", function(){
			$("#txtlinkPhoneNum").css("border", "#ccc 1px solid");
			layer.closeTips();
		});
		
		$("#txtlinkPhoneNum").live("focusout", function(){
			var txtlinkPhoneNum = $("#txtlinkPhoneNum").val();
			if(txtlinkPhoneNum == ""){
				$("#txtlinkPhoneNum").css("border", "rgb(255, 153, 0) 1px solid");
				layer.tips('请输入联系电话（只能是数字或者-）', $("#txtlinkPhoneNum"), {guide: 1});
			}		
		});

		$("#fileupload").attr("data-url", "/meileche/img.do?action=0&vehicleId=" + $("#hidVehicleId").val());
		
		$('#fileupload').fileupload({
			dataType: 'text',
	        done: function (e, data) {
	        	var result = data.result;
	        	var imgUrl= result.split("^")[0];
	        	var imgID = result.split("^")[1];
	            	var oldImg = $("#imageShow").html();
	        		var imgNum = $("#hidImgNum").val();
	        		var num = parseInt(imgNum) + 1;
	        		$("#hidImgNum").val(num);
	        		if($('#imageShow').find('img').length > 8){
	        			$("#fileupload").hide();
	        			layer.alert("亲美美，已经上传了10张图片了，最多上传10张~~~",2);
	        			
	        		}
	        		
		            var img = "<span style=\"position: relative;\"><img id=\"img"+imgID.split("-")[1]+"\" alt=\""+imgID+"\" src=\"" + imgUrl + "\" style=\"margin: 5px 5px 5px 5px;\"/></span>";
		            var imgIds = $("#hidImgIds").val();
		            if(imgIds == ""){
		            	imgIds += imgID +"*home" + "^";
		            }else{
		            	imgIds += imgID + "^";
		            }
		            
		            $("#hidImgIds").val(imgIds);
		            
		            img += oldImg;
		            $("#imageShow").html(img);
	        		addDeleteIcon("img"+imgID.split("-")[1]);
	        }
		});
		
		$("#payType").live("change", function(){
			var payType = $("#payType").val();
			if(payType == "1"){
				$("#txtQiNum").css("display", "inline");
				$("#spanQi").css("display", "inline");
			}

			if(payType != "1"){
				$("#txtQiNum").css("display", "none");
				$("#spanQi").css("display", "none");
			}
		});
	});
function zengsong(){
	$("#chk5").live("change",function(){
		if($("#chk5").attr("checked") == "checked"){
			for(var i=0;i<5;i++){
				$("#chk"+i).attr("checked", "checked");
			}
		}else{
			for(var i=0;i<5;i++){
				$("#chk"+i).removeAttr("checked");
			}
		}
		
	});
	
	$("#chk1").live("change",function(){
		if($("#chk1").attr("checked") != "checked"){
			$("#chk5").removeAttr("checked");
		}else{
			var result = "0";
			for(var n=0;n<5;n++){
				if($("#chk"+n).attr("checked") != "checked"){
					result = "1";
					break;
				}
			}
			
			if(result == "0"){
				$("#chk5").attr("checked", "checked");
			}
		}
	});
	$("#chk2").live("change",function(){
		if($("#chk2").attr("checked") != "checked"){
			$("#chk5").removeAttr("checked");
		}else{
			var result = "0";
			for(var n=0;n<5;n++){
				if($("#chk"+n).attr("checked") != "checked"){
					result = "1";
					break;
				}
			}
			
			if(result == "0"){
				$("#chk5").attr("checked", "checked");
			}
		}
	});
	$("#chk3").live("change",function(){
		if($("#chk3").attr("checked") != "checked"){
			$("#chk5").removeAttr("checked");
		}else{
			var result = "0";
			for(var n=0;n<5;n++){
				if($("#chk"+n).attr("checked") != "checked"){
					result = "1";
					break;
				}
			}
			
			if(result == "0"){
				$("#chk5").attr("checked", "checked");
			}
		}
	});
	$("#chk4").live("change",function(){
		if($("#chk4").attr("checked") != "checked"){
			$("#chk5").removeAttr("checked");
		}else{
			var result = "0";
			for(var n=0;n<5;n++){
				if($("#chk"+n).attr("checked") != "checked"){
					result = "1";
					break;
				}
			}
			
			if(result == "0"){
				$("#chk5").attr("checked", "checked");
			}
		}
	});
	$("#chk0").live("change",function(){
		if($("#chk0").attr("checked") != "checked"){
			$("#chk5").removeAttr("checked");
		}else{
			var result = "0";
			for(var n=0;n<5;n++){
				if($("#chk"+n).attr("checked") != "checked"){
					result = "1";
					break;
				}
			}
			
			if(result == "0"){
				$("#chk5").attr("checked", "checked");
			}
		}
	});
}
	function deleteImg(id){
		layer.confirm("确定要删除上传的图片吗?",function(){
			$.ajax({
				type : 'post',
				dataType : 'text',
				contentType : "application/json",
	    		url: "/meileche/img.do?action=1&imgId="+id,
	    		success: function(v){
	    			$("#img"+id.split("-")[1]).remove();
	    			$("#deleteIcon"+id.split("-")[1]).remove();
	    			layer.msg('删除图片成功~~~',1,1);
	    		}
			});
		});
		
	}
	function addDeleteIcon(eleId){
	        var deleteDiv =$("<div  onclick=\"deleteImg('"+$("#"+eleId).attr('alt')+"');\" >x</div>");
	        deleteDiv.addClass("divX");
	        deleteDiv.attr("id", "deleteIcon"+$("#"+eleId).attr('alt').split("-")[1]);
	        deleteDiv.attr("title","删除图片");
	        deleteDiv.css({position:"absolute", left: $("#"+eleId).position().left+100, top:$("#"+eleId).position().top-50});
	        $("#"+eleId).parent().append(deleteDiv);
	}
	
	function confirmAndSubmit() {
		
		if(validateInput()){
			$.ajax({
				type : 'post',
				dataType : 'text',
				contentType : "application/json",
	    		url: "login.do",
	    		success: function(v){
	    			if(v == "true"){
	    				
	    				var u = $.cookie("youleche.u");
	    				$.ajax({
	    					type : 'get',
	    					dataType : 'text',
	    					contentType : "application/json",
	    		    		url: "u.do?type=11&userName="+u,
	    		    		success: function(v){
	    	    				submitMessage(v);
	    	    				
	    	    			}
	    				});
	    			}else{
	    				$(".step1_img img").attr("src", "image/next_b.png");
	    				$(".step2_img img").attr("src", "image/next.png");
	    				$("#div_info").css("display", "none");
	    				$("#div_email").css("display", "block"); 
	    			}
	    		}
	    	}); 
		}
		
		
	}

	
	function validateInput(){
		var province = $("#sel_Province option:selected").text();
		if(province == "--省份--"){
			$("#sel_Province").css("border", "rgb(255, 153, 0) 1px solid");
			layer.tips('请选择省份', $("#sel_Province"), {guide: 2});
			return false;
		}
		
		var city = $("#sel_City option:selected").text();
		if(city == "--城市--"){
			$("#sel_City").css("border", "rgb(255, 153, 0) 1px solid");
			layer.tips('请选择城市', $("#sel_City"), {guide: 2});
			return false;
		}		
		
		var address = $("#addressAttach").val();
		if(address == ""){
			$("#addressAttach").css("border", "rgb(255, 153, 0) 1px solid");
			layer.tips('请输入具体地址', $("#addressAttach"), {guide: 1});
			return false;
		}
		
		var vehicleType = $("#bikeType").val();		
		if(vehicleType == "-1"){
			$("#divVehicleType .btn-group&.bootstrap-select").css("border", "rgb(255, 153, 0) 1px solid");
			layer.tips('请选择车辆类型', $("#divVehicleType .btn-group&.bootstrap-select"), {guide: 1});
			return false;
		}
		
		var vehicleName = $("#txt_pinpai").val();
		if(vehicleName == ""){
			$("#txt_pinpai").css("border", "rgb(255, 153, 0) 1px solid");
			layer.tips('请输入车辆品牌(只能是汉字、字母、数字、下划线)', $("#txt_pinpai"), {guide: 1});
			return false;
		}
		
		var a1 = $("#txt_Dianpu").val();
		if(a1 == ""){
			$("#txt_Dianpu").css("border", "rgb(255, 153, 0) 1px solid");
			layer.tips('请输入店铺名称(只能是汉字、字母、数字、-)', $("#txt_Dianpu"), {guide: 1});
			return false;
		}

		var batterySize = $("#txtbatterySize").val();
		if(batterySize == ""){
			$("#txtbatterySize").css("border", "rgb(255, 153, 0) 1px solid");
			layer.tips('请输入电池负数', $("#txtbatterySize"), {guide: 2});
			return false;
		}
		
		var electricitySize = $("#txtelectricitySize").val();
		if(electricitySize == ""){
			$("#txtelectricitySize").css("border", "rgb(255, 153, 0) 1px solid");
			layer.tips('请输入电流大小', $("#txtelectricitySize"), {guide: 1});
			return false;
		}

		var maxSpeed = $("#txtmaxspeed").val();
		if(maxSpeed == ""){
			$("#txtmaxspeed").css("border", "rgb(255, 153, 0) 1px solid");
			layer.tips('请输入最大速度', $("#txtmaxspeed"), {guide: 1});
			return false;
		}
		
		var workLength = $("#txtworkLength").val();
		if(workLength == ""){
			$("#txtworkLength").css("border", "rgb(255, 153, 0) 1px solid");
			layer.tips('请输入行驶距离', $("#txtworkLength"), {guide: 1});
			return false;
		}
		
		var maxWeight = $("#txtWeight").val();
		if(maxWeight == ""){
			$("#txtWeight").css("border", "rgb(255, 153, 0) 1px solid");
			layer.tips('请输入载重', $("#txtWeight"), {guide: 1});
			return false;
		}
		
		var price = $("#txtprice").val();
		if(price == ""){
			$("#txtprice").css("border", "rgb(255, 153, 0) 1px solid");
			layer.tips('请输入报价（只能是数字））', $("#txtprice"), {guide: 1});
			return false;
		}
		
		var a4 = $("#payType").val();
		if(a4=="0"){
			$("#divFenQi .btn-group&.bootstrap-select").css("border", "rgb(255, 153, 0) 1px solid");
			layer.tips('请选择是否可以分期付款', $("#divFenQi .btn-group&.bootstrap-select"), {guide: 1});
			return false;
		}
		
		if(a4== "1"){
			var fenqiNum = $("#txtQiNum").val();
			if(fenqiNum == ""){
				$("#txtQiNum").css("border", "rgb(255, 153, 0) 1px solid");
				layer.tips('请输入分期付款期数', $("#txtQiNum"), {guide: 1});
				return false;
			}else{
				a4 = fenqiNum;
			}
			
		}
		
		if(a4== "2"){
			a4 = "0";
		}
		
		var a7 = "";
		for(var i=0; i< 5; i++){
			if($("#chk" + i).attr("checked") == "checked"){
				a7 += $("#chk" + i).val();
			}
		}
		
		if(a7 == ""){
			layer.alert("请选择赠送物件", 2);
			return false;
		}
		
		var a6 = $("#infoTitle").val();
		if(a6 == ""){
			$("#infoTitle").css("border", "rgb(255, 153, 0) 1px solid");
			layer.tips('请输入信息标题', $("#infoTitle"), {guide: 1});
			return false;
		}else if(a6.length > 100){
			$("#infoTitle").css("border", "rgb(255, 153, 0) 1px solid");
			layer.tips('信息标题的长度不能超过100个汉字', $("#infoTitle"), {guide: 1});
			return false;
		}
		var linkMan = $("#txtlinkMan").val();
		if(linkMan == ""){
			$("#txtlinkMan").css("border", "rgb(255, 153, 0) 1px solid");
			layer.tips('请输入联系人', $("#txtlinkMan"), {guide: 1});
			return false;
		}
		
		var linkPhoneNum = $("#txtlinkPhoneNum").val();
		if(linkPhoneNum == ""){
			$("#txtlinkPhoneNum").css("border", "rgb(255, 153, 0) 1px solid");
			layer.tips('请输入联系电话（只能是数字或者-）', $("#txtlinkPhoneNum"), {guide: 1});
			return false;
		}
		var vehicleDesc = $("#houseDescrible").val();
		if(vehicleDesc == ""){
			$("#houseDescrible").css("border", "rgb(255, 153, 0) 1px solid");
			layer.tips('请输入车辆描述', $("#houseDescrible"), {guide: 1});
			return false;
		}
		
		return true;
	}
	
	//提交信息事件
	function commerSubmit() {
		var userName = $("#email").val();
		var password = $("#passwordShow").val();
		
		//发登陆请求
		$.ajax({
    		type: "post",
    		dataType: "text",
    		url: "u.do?type=10&userName="+userName+"&password="+password,
    		success: function(v){
    			if(v != ""){
    				submitMessage(v);
    			}else{
    				layer.alert("亲美美，用户名或者密码有误~~~", 2);
    			}
    		}
    	}); 
	}

function setVehicleAndSave(vehicleName, vehicleType,batterySize,electricitySize,vehicleDesc,workLength
		,maxSpeed,maxWeight,linkMan,linkPhoneNum,a1,price,createTime,a4,a2,a5,a6,vehicleId,sellerId,a7){
	var che = {};
	che.vehicleName = vehicleName;
	che.vehicleType = vehicleType;
	che.batterySize = batterySize;
	che.electricitySize = electricitySize;
	che.vehicleDesc = vehicleDesc;
	che.vehicleColor = " ";
	che.wheelInternalLength = "3000";
	che.workLength = workLength;
	che.vehicleModelType = "1";
	che.maxSpeed = maxSpeed;
	che.maxWeight = maxWeight;
	che.price = price;
	che.sellerId = sellerId;
	che.imageId = "imageId";
	che.linkMan = linkMan;
	che.linkPhoneNum = linkPhoneNum;
	che.A1 = a1;
	che.createTime = createTime;
	che.A4 = a4;
	che.A2 = a2;
	che.A5 = a5;
	che.A6 = a6;
	che.A7 = a7;
	che.vehicleId = vehicleId;
	var jsonData = JSON.stringify(che);
	$.ajax({
		type : 'post',
		dataType : 'json',
		contentType : "application/json",
		data : jsonData,
		url : "che.do?action=0",
		success : function(result) {
			if(result == "2"){
				layer.alert("亲美美，你今天已经发布了超过3条车辆报价信息了~~~明天再发布吧，或者删除今天发布的部分信息吧~~", 8);
			}else if(result == "1"){
				var imgIds = $("#hidImgIds").val();
				$.ajax({
					type : 'post',
					dataType : 'text',
					url : "/meileche/img.do?action=2&imgIds="+imgIds+"&vehicleId="+vehicleId,
					success : function(data) {
						
					}
				});
				switchThirdStep();
			}
			
		}
	});
}



//提交信息到服务器方法,保存成功返回true,否则返回false
function submitMessage(sellerId) {
	var createTime = $("#txt_createTime").datebox("getValue");
	var province = $("#sel_Province option:selected").text();		
	var city = $("#sel_City option:selected").text();
	var area = $("#sel_County option:selected").text();
	var address = $("#addressAttach").val();
	if(area =="--区域--"){
		area = "";
	}
	var a2 = province + city + area + address;
	var a5 = province + "-" + city + "-" + area;
	var vehicleType = $("#bikeType").val();			
	var vehicleName = $("#txt_pinpai").val();		
	var a1 = $("#txt_Dianpu").val();
	var batterySize = $("#txtbatterySize").val();		
	var electricitySize = $("#txtelectricitySize").val();
	var maxSpeed = $("#txtmaxspeed").val();
	var workLength = $("#txtworkLength").val();	
	var maxWeight = $("#txtWeight").val();		
	var price = $("#txtprice").val();
	var a4 = $("#payType").val();		
	if(a4== "1"){
		var fenqiNum = $("#txtQiNum").val();
		a4 = fenqiNum;
		
	}		
	if(a4== "2"){
		a4 = "0";
	}		
	var a6 = $("#infoTitle").val();
	var linkMan = $("#txtlinkMan").val();
	var linkPhoneNum = $("#txtlinkPhoneNum").val();
	var vehicleDesc = $("#houseDescrible").val();
	var vehicleId = $("#hidVehicleId").val();
	
	var a7 = "";
	for(var i=0; i< 5; i++){
		if($("#chk" + i).attr("checked") == "checked"){
			a7 += $("#chk" + i).val();
		}
	}
	setVehicleAndSave(vehicleName, vehicleType,batterySize,electricitySize,vehicleDesc,workLength
			,maxSpeed,maxWeight,linkMan,linkPhoneNum,a1,price,createTime,a4,a2,a5,a6,vehicleId
			,sellerId,a7);
	
}



function returnHome() {
	window.location.href = "home.jsp";
}
window.onload = function() {
	$('.selectpicker').selectpicker();
};
	
function myformatter(date) {
	var y = date.getFullYear();
	var m = date.getMonth() + 1;
	var d = date.getDate();
	return y + '-' + (m < 10 ? ('0' + m) : m) + '-'
	+ (d < 10 ? ('0' + d) : d);
}
function myparser(s) {
	if (!s)
	return new Date();
	var ss = (s.split('-'));
	var y = parseInt(ss[0], 10);
	var m = parseInt(ss[1], 10);
	var d = parseInt(ss[2], 10);
	if (!isNaN(y) && !isNaN(m) && !isNaN(d)) {
		return new Date(y, m - 1, d);
	} else {
		return new Date();
	}
}

function switchPass(){
	$("#passwordShow").css("display", "block");
	$("#password").css("display", "none");
	$("#passwordShow")[0].focus();
}

function prefixStep(){
	$(".step1_img img").attr("src", "image/next.png");
	$(".step2_img img").attr("src", "image/next_b.png");
	$("#div_info").css("display", "block");
	$("#div_email").css("display", "none"); 
}

function teachMe(){
	var vehicleName = $("#txt_pinpai").val();	
	if(vehicleName == ""){
		vehicleName = "美乐车";
	}
	var a1 = $("#txt_Dianpu").val(); //店铺名称
	if(a1 == ""){
		a1 = "美乐车车辆交易平台";
	}
	var batterySize = $("#txtbatterySize").val();
	if(batterySize == ""){
		batterySize = "48";
	}
	var electricitySize = $("#txtelectricitySize").val();
	if(electricitySize == ""){
		electricitySize = "20";
	}
	var dianchi = batterySize + "V" + electricitySize + "A";
	var title = vehicleName + "最新款，" + dianchi +"的电动车,我们的店铺在" + a1 +"，" + vehicleName +"拥有最好的专业的售后服务" ;
	$("#infoTitle").val(title);
	
	var baoxiu = "保修参数:  电机(终身)、电池（6个月）、充电器（6个月）、控制器（12个月）、车身（24个月）、其他（可商议）\n";
	
	var qingkuang = "车辆情况：  这是一款" +vehicleName + dianchi +"的电动车，充一次电可以行驶" + batterySize + "公里以上，这款电动车是最新款的电动车，非常时尚，我们的报价是整个地区最低的，如发现同地区品牌有更低报价，请联系我们，我们将直接奖励购车优惠500元。" +
			"" + vehicleName +"的电动车是经过专业人士多次检测确保车辆的合格。如果在使用过程中有小部件的非人为损坏，我们将提供终身的免费维修。";
	$("#houseDescrible").val(baoxiu + qingkuang);
}

function autoWrite(){
	var u = $.cookie("youleche.u");
	if(u == null){
		layer.alert("亲美美，只有登录的商家才能使用该功能~~~", 8);
	}else{
			$.ajax({
				type : 'post',
				dataType : 'text',
				contentType : "application/json",
	    		url: "login.do",
	    		success: function(v){
	    			if(v == "true"){
	    				$.ajax({
	    					type: "get",
	    					dataType: "text",
	    					url: "sell.do?action=0&userName="+u,
	    					success: function(v){
	    						eval("var info = " + v);
	    						$("#txt_Dianpu").val(info.shopName);
	    						$("#txtelectricitySize").val("20");
	    						$("#txtbatterySize").val("48");
	    						$("#addressAttach").val(info.shopAddress);
	    					}
	    				});
	    			}
	    		}
			});
		}
}
function viewDetails(){
	var vehicleId = $("#hidVehicleId").val();
	window.location.href = "che.do?id="+vehicleId+"&action=1";
}
function switchThirdStep(){
	$(".step1_img img").attr("src", "image/next_b.png");
	$(".step2_img img").attr("src", "image/next_b.png");
	$(".step3_img img").attr("src", "image/success.png");
	$(".step3_img img").attr("src", "image/next.png");
	$(".step3_img1 img").attr("src", "image/success.png");
	$(".step3_img1 img").css("display", "block");
	$("#div_email").css("display", "none");
	$("#div_info").hide();
	$("#div_success").css("display", "block"); 
}
function myMeile(){
	var u = $.cookie("youleche.u");
	if(u == null){
		window.location.href = "login.jsp"
	}else{
		$.ajax({
			type : 'post',
			dataType : 'text',
			contentType : "application/json",
    		url: "login.do",
    		success: function(v){
    			if(v == "true"){
    				window.location.href = "user/index.jsp";
    			}else{
    				window.location.href = "login.jsp";
    			}
    		}
		});
	}
}

function releaseOther(){
	window.location.href="list.jsp";
}
	
	